<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Promise-封装 | 9 - 同步任务 then 返回结果</title>
    <script src="./promise.js" ></script>
</head>
<body>
    <script>

        //实例化对象
        let p=new Promise((resolve,reject)=>{
            //同步任务,指的是在执行器函数当中,直接调resolve、reject、throw方式改变状态
            resolve('OK');
        });


        const res=p.then(value=>{
            //console.log(value);
            //return 'hello Promise';
            return new Promise((resolve,reject)=>{
                //resolve('success');
                //reject('oh no');
                throw 'Fail';
            });
        },reason=>{
            console.warn(reason);
        });

        console.log(res);


    </script>
</body>
</html>